<?
	FunctionsHelper::includeFiles(
		array(
			ADMINISTRATOR_CONTROLLER_DIRECTORY . 'users.php'
		)
	);
?>
<script type="text/javascript">
	$(function(){
		$('#logout').click(function(){
			varUrl = '<?=ADMINISTRATOR_CONTROLLER_PATH; ?>operations.php';
			varData = { 'id' : this.id, 'operation' : 'logout', 'controller' : 'users' };
			var funcSuccess = function(data){
				if (data == 1){
					document.location.href = document.location.protocol + '//' + document.location.host + '/nuevo/administrador';
				}
			};
			callAjax(varUrl, 'post', varData, funcSuccess);
		});
	});
</script>

<div class="fullSize" id="topBar">
	<img id="factoryName" src="<?= ADMINISTRATOR_IMAGE_PATH;?>Banner ATTE.png" />
	<?php 
	$users = new Users();
	if ($users->isLoggedUser()){ 
		$news = $users->getLoggedUser();
	?>
		<div id="topBarName"><?= utf8_encode($news->getName() . ' ' . $news->getSurname()) ;?> <a href="#" id="logout">(Salir)</a></div>
	<?php 
	}
	?>
	<span id="date"></span>
	<span id="dash">-</span>
	<span id="hour"></span>
	<div class="clear"></div>
</div>

<script type="text/javascript">
	var int=self.setInterval("UpdateDateTime()", 1000);

	$(function(){
		UpdateDateTime();
	});

	var UpdateDateTime = function(){
		var now = new Date();
		var stringNow = now.toLocaleTimeString();
		$('#hour').html(stringNow);

		var currentDate = TwoDigits(now.getDate()) +  '/' + TwoDigits(now.getMonth()+1) + '/' + now.getFullYear();
		$('#date').html(currentDate);
	}
</script>